home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / var / lib / dpkg / info / module-init-tools.preinst < prev    next >
Encoding:
Text File  |  2012-01-22  |  2.3 KB  |  104 lines

  1. #!/bin/sh -e
  2.  
  3. undivert_man() {
  4.   DSECTION=${2:-8}
  5.   for locale in '' fr/; do
  6.     dpkg-divert --remove --rename --package module-init-tools --divert \
  7.       /usr/share/man/${locale}man$DSECTION/$1.modutils.$DSECTION.gz \
  8.       /usr/share/man/${locale}man$DSECTION/$1.$DSECTION.gz > /dev/null
  9.   done
  10. }
  11.  
  12. rm_conffile_md5() {
  13.   local file=$1
  14.   local md5=$2
  15.   if [ -f $file ] && echo "$md5  $file" | md5sum -c 2> /dev/null; then
  16.     rm $file
  17.   fi
  18. }
  19.  
  20. rm_conffile() {
  21.   mv_conffile "$1" "$1.dpkg-bak"
  22. }
  23.  
  24. mv_conffile() {
  25.   local package='module-init-tools'
  26.   local name="$1"
  27.   local newname="$2"
  28.  
  29.   [ -e "$name" ] || return 0
  30.  
  31.   local md5="$(md5sum $name | sed -e 's/ .*//')"
  32.   oldmd5="$(dpkg-query -W -f='${Conffiles}' $package | \
  33.     sed -n -e "\' $name ' { s/ obsolete$//; s/.* //; p }")"
  34.  
  35.   if [ "$md5" = "$oldmd5" ]; then
  36.     rm -f "$name"
  37.   else
  38.     mv "$name" "$newname"
  39.   fi
  40. }
  41.  
  42. upgrade_quirks() {
  43.   # $2 is non-empty when installing from the "config-files" state
  44.   [ "$2" ] || return 0
  45.  
  46.   if dpkg --compare-versions $2 lt 3.10-3; then
  47.   if dpkg --compare-versions $2 lt 3.1-pre11-1; then
  48.   if dpkg --compare-versions $2 lt 3.2-pre9-4; then
  49.   if dpkg --compare-versions $2 lt 3.1-pre2-1; then
  50.  
  51.   echo 'Upgrading from packages older than 3.1-pre2-1 is not supported.'
  52.   echo 'Please purge module-init-tools before installing this package.'
  53.   exit 1
  54.  
  55.   fi # lt 3.1-pre2-1
  56.  
  57.   rm -f /usr/share/man/man8/kallsyms.8.gz /usr/share/man/man8/ksyms.8.gz
  58.   for cmd in kallsyms ksyms; do
  59.     undivert_man $cmd
  60.   done
  61.  
  62.   fi # lt 3.2-pre9-4
  63.  
  64.   # remove an obsolete conffile, which was replaced by .../x86_64
  65.   if [ "$(dpkg --print-architecture)" = amd64 ]; then
  66.     rm_conffile_md5 /etc/modprobe.d/arch/i386 688ef8c36b20113c46ec631e6c9effd4
  67.   fi
  68.  
  69.   fi # lt 3.1-pre11-1
  70.  
  71.   for file in i386 x86_64 mips s390 parisc sparc powerpc.apus \
  72.        powerpc.generic powerpc.pmac m68k.amiga m68k.atari m68k.generic; do
  73.     rm_conffile /etc/modprobe.d/arch/$file
  74.   done
  75.   rmdir /etc/modprobe.d/arch/ 2> /dev/null || true
  76.   if [ -L /etc/modprobe.d/arch-aliases \
  77.       -a ! -e /etc/modprobe.d/arch-aliases ]; then
  78.     rm /etc/modprobe.d/arch-aliases
  79.   fi
  80.  
  81.   mv_conffile /etc/modprobe.d/aliases /etc/modprobe.d/aliases.conf
  82.  
  83.   fi # lt 3.10-3
  84. }
  85.  
  86. case "$1" in
  87.     install|upgrade)
  88.  
  89.     upgrade_quirks "$@"
  90.     ;;
  91.  
  92.     abort-upgrade)
  93.     ;;
  94.  
  95.     *)
  96.     echo "$0 called with unknown argument '$1'" >&2
  97.     exit 1
  98.     ;;
  99. esac
  100.  
  101.  
  102.  
  103. exit 0
  104.